package org.flint.data.structure.stack;

import org.flint.data.structure.array.Array;

/**
 * @author flint92
 */
public class ArrayStack<E> implements Stack<E> {

    private final Array<E> array;

    public ArrayStack() {
        this.array = new Array<>();
    }

    public ArrayStack(int capacity) {
        this.array = new Array<>(capacity);
    }

    @Override
    public void push(E o) {
        this.array.addLast(o);
    }

    @Override
    public E pop() {
        return this.array.removeLast();
    }

    @Override
    public E peek() {
        return this.array.getLast();
    }

    @Override
    public int getSize() {
        return this.array.getSize();
    }

    @Override
    public boolean isEmpty() {
        return this.array.isEmpty();
    }
}
